package resource

import (
	"project-info/src/handle/resource"
	"project-info/src/router/req"
	"project-info/src/router/variable"

	"github.com/gin-gonic/gin"
)

func init() {
	variable.InitRouteFunc = append(variable.InitRouteFunc, InitResourceRoute)
}

func InitResourceRoute(e *gin.Engine) {
	resourceGroup := req.NewGroup("/resource").NeedToken().SetUpGroup(e)

	reqs := []*req.Conf{
		req.NewPost("/add", resource.AddResource),
		req.NewPost("/page", resource.PageResource),
		req.NewDelete("/delete", resource.DeleteResource),
		req.NewPost("/bindPrivilege", resource.BindResource),
		req.NewPost("/getPrivilege", resource.GetResourcePrivilege),
		req.NewPost("/options", resource.GetResourceOptions).WithMiddleware(req.DataPermissionHandlerConfig()),
	}
	req.BatchSetUpRouter(resourceGroup, reqs)
}
